package com.yicheng.controller;

import com.yicheng.controller.utils.R;
import com.yicheng.entity.Image;
import com.yicheng.entity.Swiper;
import com.yicheng.service.SwiperService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/swiper")
public class SwiperController {

    @Autowired
    private SwiperService service;

    @GetMapping("/getSwiper")
    public R getSwiper(Integer cate){
        R r = new R();
        try {
            List<Swiper> imageList = service.getSwipers(cate);
            r.setList(imageList);
            r.setMsg("获取该种类图片成功");
        }catch (Exception e){

            r.setMsg(e.getMessage());
            r.setStatus(false);
        }
        return r;
    }
}
